<template>
  <div class="app-container">

    <u-page title="季度滞纳金维护">
      <u-filtered>
        <el-form :inline="true" :model="listQuery" class="search-form">
          <el-form-item label="合同号" prop="contractNumber">
            <el-input v-model="listQuery.contractNumber" style="width: 155px" />
          </el-form-item>
          <el-form-item>
            <el-button type="primary" icon="el-icon-search" @click="handleFilter">查询</el-button>
          </el-form-item>
          <el-form-item>
            <el-button type="primary" icon="el-icon-edit" style="margin-left: 20px" @click="handleAddHoliday">新增</el-button>
          </el-form-item>
        </el-form>
      </u-filtered>

      <u-table
        :data="list"
        :loading="listLoading"
        :options="listOptions"
        :columns="columns"
        :pagination.sync="listQuery"
        :fetch="hdlList"
        @selection-change="hdlSelectChange"
      >
        <template v-slot:right>
          <el-table-column label="操作" align="center" fixed="right">
            <template slot-scope="{ row }">
              <el-button type="text" @click="handleEdit(row)">编辑</el-button>
              <el-button type="text" @click="handleDelete(row)">删除</el-button>
            </template>
          </el-table-column>
        </template>
      </u-table>
    </u-page>
    <!-- 滞纳金信息 -->
    <holiday-info v-model="dialogHolidayInfoVisible" :data="pickData"/>
  </div>
</template>
<script>
import HolidayInfo from './components/HolidayInfo'
export default {
  components: { HolidayInfo },
  data() {
    return {
      api: this.$u.api.OpcenHoliday,
      // 当前年份
      currentYear: new Date().getFullYear(),
      // 年份
      years: [],
      statusList: [{ value: 0, label: '关闭' }, { value: 1, label: '开启' }],
      infotable: false,
      listOptions: {
        mutiSelect: true,
        stripe: true
      },
      listLoading: false,
      list: [],
      form: {
        id: '',
        updateflag: false,
        date: '',
        name: '',
        isoffday: 1,
        status: 1,
        remarkquarterholiday: ''
      },
      // 选中的数据
      pickData: {},
      formLabelWidth: '80px',
      // 表格
      columns: [
        {
          prop: 'contractNumber',
          label: '合同号'
        },
        {
          prop: 'deductionNumber',
          label: '扣款单号'
        },
        {
          prop: 'deductionName',
          label: '扣款名称'
        },
        {
          prop: 'overdueFineStandard',
          label: '滞纳金标准'
        },
        {
          prop: 'paymentTime',
          label: '缴费时间'
        },
        {
          prop: 'creator',
          label: '创建人员'
        }
      ],
      listQuery: {
        page: 1,
        pageSize: 20,
        totalCount: 1,
        contractNumber: ''
      },
      dialogHolidayInfoVisible: false
    }
  },
  methods: {
    handleAddHoliday() {
      // self.infotable = true
      this.pickData = {}
      this.dialogHolidayInfoVisible = true
    },
    handleFilter() {
      this.hdlQhList()
    },
    hdlQhList() {
      const self = this
      // 打开加载状态
      self.listLoading = true
      self.api.qhlist(self.listQuery).then(res => {
        // 获取分页列表数据
        self.list = res.data.data
        // 获取分页数据,总页数
        self.listQuery.totalCount = res.data.total
        // 关闭加载状态
        setTimeout(() => {
          self.listLoading = false
        }, 0.5 * 1000)
      })
    },
    // 编辑
    handleEdit(row) {
      const self = this
      // 初始化数据源
      self.pickData = row
      // 打开编辑状态
      self.dialogHolidayInfoVisible = true
    },
    // 删除
    handleDelete(row) {
      const self = this
      self.api.deleteqh(row.uuid).then(res => {
        // 通知信息
        self.$u.msg('删除成功！')
        this.hdlQhList()
      }).catch(() => {
        self.$u.msg('删除失败，请重试或联系管理员')
        return
      })
    }
  }
}
</script>
<style>
.el-select .el-input {
  width: 220px;
}
</style>
<style lang="scss" scoped>
.app-container{
}
</style>
